* Replication data for Presidential Instability in Latin America: Why Institutionalized Parties Matter
* Christopher A. Martínez
* November 13, 2019

use "survival.dta", clear

stset dateout,  failure(event=1)  id(adm) origin(time datein) exit(time .) 

***TABLE 1

streg   c.partyins##c.partyins maj antigov scandals	, vce(cluster country) dist(weibull) nohr						// model 1
streg 	c.partyins##c.partyins maj antigov ecogrowth	, vce(cluster country) dist(weibull) nohr					// model 2
streg 	c.partyins##c.partyins maj antigov hyperinflation	, vce(cluster country) dist(weibull) nohr				// model 3
streg 	c.partyins##c.partyins maj scandals hyperinflation	, vce(cluster country) dist(weibull) nohr				// model 4
streg 	c.partyins##c.partyins antigov ecogrowth hyperinflation	, vce(cluster country) dist(weibull) nohr			// model 5



***FIGURE 1

streg 	c.partyins##c.partyins maj antigov scandals	, vce(cluster country) dist(weibull) nohr										// model 1
stcurve, surv at1(partyins=15) at2(partyins=35) at3(partyins=60) scheme(s2mono) title("Model 1",size(medium)) ///
ylabel(0.7(0.1)1) ytitle("") xtitle("analysis time (days)") mlabsize(small) legend(size(small)  ///
order(1 "Party institutionalization = 15" 2 "Party institutionalization = 35" 3 "Party institutionalization = 60"))
graph save s1
streg 	c.partyins##c.partyins maj antigov ecogrowth	, vce(cluster country) dist(weibull) nohr									// model 2
stcurve, surv at1(partyins=15) at2(partyins=35) at3(partyins=60) scheme(s2mono) title("Model 2",size(medium)) /// 
ylabel(0.7(0.1)1) ytitle("") xtitle("analysis time (days)") mlabsize(small) legend(size(small)) 
graph save s2
streg 	c.partyins##c.partyins maj antigov hyperinflation	, vce(cluster country) dist(weibull) nohr								// model 3
stcurve, surv at1(partyins=15) at2(partyins=35) at3(partyins=60) scheme(s2mono)title("Model 3",size(medium)) /// 
ylabel(0.7(0.1)1) ytitle("") xtitle("analysis time (days)") mlabsize(small) legend(size(small)) 
graph save s3
streg 	c.partyins##c.partyins maj scandals hyperinflation	, vce(cluster country) dist(weibull) nohr								// model 4
stcurve, surv at1(partyins=15) at2(partyins=35) at3(partyins=60) scheme(s2mono) title("Model 4",size(medium)) ///
ylabel(0.7(0.1)1) ytitle("") xtitle("analysis time (days)") mlabsize(small) legend(size(small)) 
graph save s4
streg 	c.partyins##c.partyins antigov ecogrowth hyperinflation	, vce(cluster country) dist(weibull) nohr							// model 5
stcurve, surv at1(partyins=15) at2(partyins=35) at3(partyins=60) scheme(s2mono) title("Model 5",size(medium)) ///
ylabel(0.7(0.1)1) ytitle("") xtitle("analysis time (days)") mlabsize(small) legend(size(small)) 
graph save s5

grc1leg s1.gph s2.gph s3.gph s4.gph s5.gph , scheme(s2mono) ///
ycommon title("")  l2title("Survival",size(medium))



***FIGURE 2

**Figure 2.a
streg 	c.partyins##c.partyins maj antigov scandals	, vce(cluster country) dist(weibull) nohr										// model 1
stcurve, hazard at1(antigov=0 maj=60) at2(antigov=3 maj=60) at3(antigov=6 maj=60) scheme(s2mono) ylabel(0(0.0001)0.0004, labsize(3)) /// 
title("Legislative Support = 60%",size(medium)) xlabel(0(500)2500, labsize(3)) ytitle("")  ///
xtitle("analysis time (days)") mlabsize(vsmall) legend(size(small) order(1 "Anti-gov.=0" 2 "Anti-gov.=3" 3 "Anti-gov.=6"))
graph save a1
stcurve, hazard at1(antigov=0 partyins=60) at2(antigov=3 partyins=60) at3(antigov=6 partyins=60) scheme(s2mono) ylabel(0(0.0001)0.0004, labsize(3)) ///
title("Party institutionalization = 60",size(medium)) xlabel(0(500)2500, labsize(3)) ytitle("")  ///
xtitle("analysis time (days)") mlabsize(vsmall) legend(size(small) order(1 "Anti-gov.=0" 2 "Anti-gov.=3" 3 "Anti-gov.=6"))
graph save a2

grc1leg a1.gph a2.gph, scheme(s2mono) ycommon title("") ///
l2title("Hazard function",size(medium))
graph save 2a

**Figure 2.b
streg 	c.partyins##c.partyins maj antigov scandals	, vce(cluster country) dist(weibull) nohr										// model 1
stcurve, hazard at1(scandals=0 maj=60) at2(scandals=3 maj=60) at3(scandals=6 maj=60) scheme(s2mono) ylabel(0(0.0001)0.0004, labsize(3)) ///
title("Legislative Support = 60%",size(medium)) xlabel(0(500)2500, labsize(3)) ytitle("")  ///
xtitle("analysis time (days)") mlabsize(vsmall) legend(size(small) order(1 "Scandals=0" 2 "Scandals=3" 3 "Scandals=6")) 
graph save b1
stcurve, hazard at1(scandals=0 partyins=60) at2(scandals=3 partyins=60) at3(scandals=6 partyins=60) scheme(s2mono) ylabel(0(0.0001)0.0004, labsize(3)) ///
title("Party institutionalization = 60",size(medium)) xlabel(0(500)2500, labsize(3)) ytitle("")  ///
xtitle("analysis time (days)") mlabsize(vsmall) legend(size(small) order(1 "Scandals=0" 2 "Scandals=3" 3 "Scandals=6")) 
graph save b2

grc1leg b1.gph b2.gph, scheme(s2mono) ycommon title("") ///
l2title("Hazard function",size(medium))
graph save 2b

graph combine 2a.gph 2b.gph

***ROBUSTNESS CHECKS

*** (A) Combinations
eststo clear
eststo: quietly  streg 	c.partyins##c.partyins maj antigov scandals	, vce(cluster country) dist(weibull) nohr						// model 1
eststo: quietly  streg 	c.partyins##c.partyins maj antigov ecogrowth	, vce(cluster country) dist(weibull) nohr					// model 2
eststo: quietly  streg 	c.partyins##c.partyins maj antigov hyperinflation	, vce(cluster country) dist(weibull) nohr				// model 3
eststo: quietly  streg 	c.partyins##c.partyins maj scandals hyperinflation	, vce(cluster country) dist(weibull) nohr				// model 4
eststo: quietly  streg 	c.partyins##c.partyins antigov ecogrowth hyperinflation	, vce(cluster country) dist(weibull) nohr			// model 5
eststo: quietly  streg 	c.partyins##c.partyins maj ecogrowth scandals	, vce(cluster country) dist(weibull) nohr
eststo: quietly  streg 	c.partyins##c.partyins maj ecogrowth hyperinflation	, vce(cluster country) dist(weibull) nohr
eststo: quietly  streg 	c.partyins##c.partyins antigov ecogrowth scandals	, vce(cluster country) dist(weibull) nohr
eststo: quietly  streg 	c.partyins##c.partyins antigov scandals hyperinflation	, vce(cluster country) dist(weibull) nohr
eststo: quietly  streg 	c.partyins##c.partyins ecogrowth scandals hyperinflation	, vce(cluster country) dist(weibull) nohr
eststo: quietly  streg   maj antigov scandals ecogrowth hyperinflation, vce(cluster country) dist(weibull) nohr
esttab,  label title(This is a regression table) nonumbers mtitles("1" "2" "3" "4" "5" ///
"6" "7" "8" "9" "10" "11") p(a2) scalars("ll Log lik.")  aic

*** (B.1) Cox's Proportional Hazards Model
eststo clear
eststo: quietly stcox 	c.partyins##c.partyins maj antigov ecogrowth	, vce(cluster country)
eststo: quietly stcox 	c.partyins##c.partyins maj antigov scandals	, vce(cluster country)
eststo: quietly stcox 	c.partyins##c.partyins maj antigov hyperinflation	, vce(cluster country)
eststo: quietly stcox 	c.partyins##c.partyins maj ecogrowth scandals	, vce(cluster country)
eststo: quietly stcox 	c.partyins##c.partyins maj ecogrowth hyperinflation	, vce(cluster country)
eststo: quietly stcox 	c.partyins##c.partyins maj scandals hyperinflation	, vce(cluster country)
eststo: quietly stcox 	c.partyins##c.partyins antigov ecogrowth scandals	, vce(cluster country)
eststo: quietly stcox 	c.partyins##c.partyins antigov ecogrowth hyperinflation	, vce(cluster country)
eststo: quietly stcox 	c.partyins##c.partyins antigov scandals hyperinflation	, vce(cluster country)
eststo: quietly stcox 	c.partyins##c.partyins ecogrowth scandals hyperinflation	, vce(cluster country)
eststo: quietly stcox 	maj ecogrowth scandals antigov hyperinflation	, vce(cluster country)
esttab,  label title(This is a regression table) nonumbers mtitles("1" "2" "3" "4" "5" "6" "7" "8" "9" "10" "11") p(a2) scalars("ll Log lik.")

*** (B.2) Flexible Parametric Model for Survival Analysis
eststo clear
eststo: quietly stpm2 	c.partyins##c.partyins maj antigov ecogrowth	, df(3) scale(hazard) eform theta(est) vce(cluster country)
eststo: quietly stpm2 	c.partyins##c.partyins maj antigov scandals	, df(3) scale(hazard) eform theta(est) vce(cluster country)
eststo: quietly stpm2 	c.partyins##c.partyins maj antigov hyperinflation	, df(3) scale(hazard) eform theta(est) vce(cluster country)
eststo: quietly stpm2 	c.partyins##c.partyins maj ecogrowth scandals	, df(3) scale(hazard) eform theta(est) vce(cluster country)
eststo: quietly stpm2 	c.partyins##c.partyins maj ecogrowth hyperinflation	, df(3) scale(hazard) eform theta(est) vce(cluster country)
eststo: quietly stpm2 	c.partyins##c.partyins maj scandals hyperinflation	, df(3) scale(hazard) eform theta(est) vce(cluster country)
eststo: quietly stpm2 	c.partyins##c.partyins antigov ecogrowth scandals	, df(3) scale(hazard) eform theta(est) vce(cluster country)
eststo: quietly stpm2 	c.partyins##c.partyins antigov ecogrowth hyperinflation	, df(3) scale(hazard) eform theta(est) vce(cluster country)
eststo: quietly stpm2 	c.partyins##c.partyins antigov scandals hyperinflation	, df(3) scale(hazard) eform theta(est) vce(cluster country)
eststo: quietly stpm2 	c.partyins##c.partyins ecogrowth scandals hyperinflation	, df(3) scale(hazard) eform theta(est) vce(cluster country)
eststo: quietly stpm2 	maj ecogrowth scandals antigov hyperinflation	, df(3) scale(hazard) eform theta(est) vce(cluster country)
esttab,  label title(This is a regression table) nonumbers mtitles("1" "2" "3" "4" "5" "6" "7" "8" "9" "10" "11") p(a2) scalars("ll Log lik.")

*** (B.3) Multilevel: Mixed-Effects Weibull Proportional Hazards Regression
eststo clear
eststo:   quietly mestreg	c.partyins##c.partyins maj antigov ecogrowth	|| country_id:|| presid:, distribution(weibull) vce(robust) nohr
eststo:   quietly mestreg	c.partyins##c.partyins maj antigov scandals	|| country_id:|| presid:, distribution(weibull) vce(robust) nohr
eststo:   quietly mestreg	c.partyins##c.partyins maj antigov hyperinflation	|| country_id:|| presid:, distribution(weibull) vce(robust) nohr
eststo:   quietly mestreg	c.partyins##c.partyins maj ecogrowth scandals	|| country_id:|| presid:, distribution(weibull) vce(robust) nohr
eststo:   quietly mestreg	c.partyins##c.partyins maj ecogrowth hyperinflation	|| country_id:|| presid:, distribution(weibull) vce(robust) nohr
eststo:   quietly mestreg	c.partyins##c.partyins maj scandals hyperinflation	|| country_id:|| presid:, distribution(weibull) vce(robust) nohr
eststo:   quietly mestreg	c.partyins##c.partyins antigov ecogrowth scandals	|| country_id:|| presid:, distribution(weibull) vce(robust) nohr
eststo:   quietly mestreg	c.partyins##c.partyins antigov ecogrowth hyperinflation	|| country_id:|| presid:, distribution(weibull) vce(robust) nohr
eststo:   quietly mestreg	c.partyins##c.partyins antigov scandals hyperinflation	|| country_id:|| presid:, distribution(weibull) vce(robust) nohr
eststo:   quietly mestreg	c.partyins##c.partyins ecogrowth scandals hyperinflation	|| country_id:|| presid:, distribution(weibull) vce(robust) nohr
eststo:   quietly mestreg	maj antigov ecogrowth scandals hyperinflation	|| country_id:|| presid:, distribution(weibull) vce(robust) nohr
esttab,  label title(This is a regression table) nonumbers mtitles("1" "2" "3" "4" "5" "6" "7" "8" "9" "10" "11") p(a2) scalars("ll Log lik." "theta")
